home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / Asm / AB3DIIsrc / Graphics / FASTC2P.LZH / c2p / Startup_code.i < prev    next >
Encoding:
Text File  |  1995-10-13  |  3.2 KB  |  179 lines

  1.     section StartupRoutines,code
  2.  
  3.     include "Include:lvo3.0/exec_lib.i"
  4.     include "Include:lvo3.0/dos_lib.i"
  5.  
  6. _SaveSystem:
  7.     OpenLib        DosName,DosBase
  8.     OpenLib        GfxName,GfxBase
  9.  
  10.     bsr    _GetVBR
  11.  
  12.     IFD    KillSystem
  13.  
  14.     move.l    4.w,a6
  15.     CALL    Disable(a6)
  16.  
  17.     bsr    _SaveDMA_Interrupt
  18.     ENDIF
  19.  
  20.     IFD    NewCopperList
  21.     bsr    _RemoveSystemScreen
  22.     ENDIF
  23.  
  24.     rts
  25.  
  26.  
  27. _RestoreSystem:
  28.     IFD    KillSystem
  29.  
  30.     BlitterWait
  31.     bsr    _RestoreDMA_Interrupt
  32.  
  33.     move.l    4.w,a6
  34.     CALL    Enable(a6)
  35.  
  36.     ENDIF
  37.  
  38.     IFD    NewCopperList
  39.     bsr    _RestoreSystemScreen
  40.     ENDIF
  41.     
  42.     CloseLib    DosBase
  43.     CloseLib    GfxBase
  44.  
  45.     moveq    #0,d0
  46.     rts
  47.  
  48.  
  49. ;-----Misc routines--------------------------------------------------
  50.  
  51. _GetVBR:
  52.          moveq    #0,d0            ; clear
  53.          move.l    4.w,a6
  54.          btst.b    #0,296+1(a6)        ; are we at least a 68010?
  55.          beq.b    .Just_68000        ; nope.
  56.          lea.l    .VBR_Exception(pc),a5    ; addr of function to get VBR
  57.          CALL    Supervisor(a6)        ; supervisor state
  58. .Just_68000:
  59.          move.l    d0,VectorBase        ; save it for later.
  60.     rts
  61. .VBR_Exception:
  62.          movec   vbr,d0
  63.          rte
  64.  
  65. ;------------------------------------------------
  66.  
  67. _SaveInterrupts:
  68.     move.l    VectorBase,a0
  69.  
  70.     move.l    $64(a0),_OldLevel1
  71.     move.l    $68(a0),_OldLevel2
  72.     move.l    $6c(a0),_OldLevel3
  73.     move.l    $70(a0),_OldLevel4
  74.     move.l    $74(a0),_OldLevel5
  75.     move.l    $78(a0),_OldLevel6
  76.     move.l    $7c(a0),_OldLevel7
  77.  
  78.     rts
  79. ;------------------------------------------------
  80.  
  81. _RestoreInterrupts:
  82.     move.l    VectorBase,a0
  83.  
  84.     move.l    _OldLevel1,$64(a0)
  85.     move.l    _OldLevel2,$68(a0)
  86.     move.l    _OldLevel3,$6c(a0)
  87.     move.l    _OldLevel4,$70(a0)
  88.     move.l    _OldLevel5,$74(a0)
  89.     move.l    _OldLevel6,$78(a0)
  90.     move.l    _OldLevel7,$7c(a0)
  91.  
  92.     rts
  93. ;------------------------------------------------
  94.  
  95. _RemoveSystemScreen:
  96.     move.l    GfxBase,a6
  97.  
  98.     move.l    34(a6),_WBView
  99.     sub.l    a1,a1
  100.     CALL    LoadView(a6)
  101.     CALL    WaitTOF(a6)
  102.     CALL    WaitTOF(a6)
  103.     rts
  104.  
  105. ;------------------------------------------------
  106.  
  107. _RestoreSystemScreen:
  108.     move.l    GfxBase,a6
  109.     move.l    _WBView,a1
  110.     CALL    LoadView(a6)
  111.     CALL    WaitTOF(a6)
  112.     CALL    WaitTOF(a6)
  113.     move.l    38(a6),$dff080
  114.     move.w    #0,$dff088
  115.     rts
  116.  
  117. ;------------------------------------------------
  118. _SaveDMA_Interrupt:
  119.     move.w    $dff01c,_INTENAR    ;SAVE READ INTERRUPT ENABLE;
  120.     or.w    #$C000,_INTENAR        ;or two last bit til INTENAR
  121.     move.w    $dff002,_DMAdata    ;
  122.     or.w    #$8100,_DMAdata        ;or it off!!!
  123.  
  124.     IFD    SaveInterrupts
  125.     bsr    _SaveInterrupts
  126.     ENDIF
  127.  
  128.     rts
  129.  
  130. ;------------------------------------------------
  131.  
  132. _RestoreDMA_Interrupt:
  133.  
  134.     move.l    #$7fff7fff,$dff096;
  135.     move.w    #$7fff,$dff09a;
  136.  
  137.     IFD    SaveInterrupts
  138.     bsr    _RestoreInterrupts
  139.     ENDIF
  140.  
  141.     move.w    _DMAdata,$dff096
  142.     move.w    _INTENAR,$dff09A;
  143.     rts
  144.     
  145. ;------------------------------------------------
  146. ;------------------------------------------------
  147. ;------------------------------------------------
  148. ;------------------------------------------------
  149. ;------------------------------------------------
  150. ;------------------------------------------------
  151.  
  152.     
  153. ;-----Data Storage---------------------------------------------------
  154.  
  155. DosBase:    dc.l    0
  156. GfxBase:    dc.l    0
  157.  
  158. DosName:    dc.b    "dos.library",0
  159. GfxName:    dc.b    "graphics.library",0
  160.         even
  161.  
  162. VectorBase:        dc.l    0
  163.  
  164. ;-----Internal Data----------------------------------------------------
  165.  
  166. _WBView:    dc.l    0
  167. _INTENAR:    dc.w    0
  168. _DMAdata:    dc.w    0
  169.  
  170. _OldLevel1:    dc.l    0
  171. _OldLevel2:    dc.l    0
  172. _OldLevel3:    dc.l    0
  173. _OldLevel4:    dc.l    0
  174. _OldLevel5:    dc.l    0
  175. _OldLevel6:    dc.l    0
  176. _OldLevel7:    dc.l    0
  177.  
  178.  
  179.